class Solution {
    public String longestPalindrome(String s) {
        //回文子串 ，正反看都相同的字符串
        //动态规划解决回文子串
        if(s.isEmpty()){
            return null;
        }
        int len = s.length();
        if(len<=1){
            return s;
        }
        //创建一个状态容器，存放状态
        boolean dp[][] = new boolean[len][len];
        for(int i=0;i<len;i++){
            dp[i][i]=true;
        }
        //最大值
        int max = 1,start=0;
        //创建一个矩形的状态图
        for(int j = 1;j<len; j++){
            for(int i =0 ; i<len-1 && i<j; i++){
                //当i=j时 ，属于本身 一定为回文子串
                if(s.charAt(i)!=s.charAt(j)){
                    dp[i][j]=false;
                }
                else{
                    if(j-i<3){
                        dp[i][j]=true;
                    }else
                    {
                        dp[i][j]=dp[i+1][j-1];
                    }
                }
                if( dp[i][j] && j-i+1>max ){
                    max =j-i+1;
                    start = i;
                }
            }
        }
        return s.substring(start , start+max);
    }
}

public class MainClass {
    public static String stringToString(String input) {
        if (input == null) {
            return "null";
        }
        return Json.value(input).toString();
    }
    
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = in.readLine()) != null) {
            String s = stringToString(line);
            
            String ret = new Solution().longestPalindrome(s);
            
            String out = (ret);
            
            System.out.print(out);
        }
    }
}